﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DEEBCG.ExternalLib.CompanyAPI.Model
{
    /// <summary>
    /// 在床状态本报表信息
    /// </summary>
    public class OnBedStatusReportInfo
    {
        public DateTime Time
        {
            set;
            get;
        }

        public double? OnBedStaticInterval
        {
            set;
            get;
        } = null;

        public double? OnBedStaticCount
        {
            set;
            get;
        } = null;

        public double? OnBedActivityInterval
        {
            set;
            get;
        } = null;

        public double? OnBedActivityCount
        {
            set;
            get;
        } = null;

        public double? LeaveBedInterval
        {
            set;
            get;
        } = null;

        public double? LeaveBedCount
        {
            set;
            get;
        } = null;

        public double? LeavePillowInterval
        {
            set;
            get;
        } = null;

        public double? LeavePillowCount
        {
            set;
            get;
        } = null;

        public double? OfflineInterval
        {
            set;
            get;
        } = null;

        public double? OfflineCount
        {
            set;
            get;
        } = null;

        public double? MaxOnBedStaticInterval
        {
            set;
            get;
        } = null;

        public double? MaxOnBedActivityInterval
        {
            set;
            get;
        } = null;

        public double? MaxLeaveBedInterval
        {
            set;
            get;
        } = null;

        public double? MaxLeavePillowInterval
        {
            set;
            get;
        } = null;

        public double? MaxOfflineInterval
        {
            set;
            get;
        } = null;

        /// <summary>
        /// 区间时长（秒）
        /// </summary>
        public double? Interval { set; get; } = null;


        /// <summary>
        /// 获取在床比例
        /// </summary>
        /// <returns></returns>
        public double GetOnBedScale()
        {
            double s = 0;
            if (OnBedActivityInterval != null && OnBedStaticInterval != null && LeavePillowInterval != null &&
                OfflineInterval != null)
            {
                s = (Convert.ToDouble(OnBedActivityInterval) + Convert.ToDouble(OnBedStaticInterval)) / Convert.ToDouble(Interval);
                //如果在床比例大于50的，同时有掉线的情况发生，认为掉线的这期间也在床上
                if (s > 0.5 && OfflineInterval > 0)
                {
                    s = (Convert.ToDouble(OnBedActivityInterval) + Convert.ToDouble(OnBedStaticInterval) + Convert.ToDouble(LeaveBedInterval)) / Convert.ToDouble(Interval);
                }
            }
            return s;
        }

    }
}
